package com.linc.facerecognitionsi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.linc.facerecognitionsi.R;

import java.util.ArrayList;
import java.util.List;


public class NameListAdapter extends BaseAdapter {
	public List<String> itemsInfos;
	private LayoutInflater inflater;

	static class ViewHolder {
		TextView name;
	}

	public NameListAdapter(Context mContext) {
		super();
		itemsInfos=new ArrayList<String>();
		inflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return itemsInfos.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.name_list_item, null);
			holder = new ViewHolder();
			holder.name = (TextView) convertView
					.findViewById(R.id.name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
//		HashMap<String, String> ItemsInfo = itemsInfos.get(position);
//		String name = (String) ItemsInfo.get("name");
        String name = itemsInfos.get(position);
		holder.name.setText(name);
		return convertView;
	}
}
